#ifndef CLIENTMODULE_H
#define CLIENTMODULE_H

#include <QMainWindow>
#include <QMenu>
#include <QMenuBar>
#include <QToolBar>
#include <QStatusBar>
#include <QDialog>
#include <QSqlDatabase>
#include <QSqlRelationalTableModel>
#include <QTableView>
#include <QMessageBox>
#include <QAction>
#include <QGroupBox>
#include <QGridLayout>
#include <QFormLayout>
#include <QRadioButton>
#include <QButtonGroup>
#include <QLabel>
#include <QLineEdit>
#include <QDebug>
#include <QModelIndex>
#include <QPrinter>
#include <QPrintDialog>
#include <QPainter>
#include <QDate>
#include <QKeyEvent>
#include <QKeySequence>
#include <QShortcut>
#include <QProcess>
#include <QHeaderView>

#include "CustomToolbar.h"
#include "NewClient.h"
#include "EditClient.h"
#include "DeletedClient.h"
#include "ClientReport.h"
#include "ClientReportIntern.h"

class ClientModule : public QMainWindow
{
    Q_OBJECT

public:
   explicit ClientModule(QWidget *parent);

signals:

public slots:
    void AddClientBtn();
    void DeleteClientBtn();
    void EditClientBtn();
    void UpdateClientListBtn();
    void PrintClientBtn();
    void PrintInternListBtn();
    void DeletedClientListBtn();
    void CorrectViewOfModel();

    void ViewCreatedToday();
    void ViewCreatedLastMonth();
    void ViewCreatedCurrentMonth();
    void ViewCreatedLastYear();
    void ViewCreatedCurrentYear();

    void FindRazonSocial();
    void FilterRazonSocial();
    void FindResponsable();
    void FilterResponsable();
    void FindFechaAlta();
    void FilterFechaAlta();

private:
    /**
     * @brief client_toolbar
     */
    CustomModulesToolbar *client_toolbar;
    void CreateClientToolBar();
    void DeleteClientToolBar();
    void EditClientToolBar();
    void UpdateClientListToolBar();
    void DeletedClientListToolBar();
    void PrintClientToolBar();
    void PrintListadoInternoToolBar();

    void BackupBeforeDeleteClient();

    QAction *new_client;
    QAction *delete_client;
    QAction *edit_client;
    QAction *print_client;
    QAction *print_intern_client;
    QAction *update_clientList;
    QAction *deleted_client_list;
    QListView *filters_utils;

    QRadioButton *created_today;
    QRadioButton *created_last_month;
    QRadioButton *created_current_month;
    QRadioButton *created_last_year;
    QRadioButton *created_current_year;

    QRadioButton *find_razon_social;
    QRadioButton *find_responsable;
    QRadioButton *find_fecha_alta;

    QLineEdit *find_line;

    QString filterClient;
    QString persona;

    void CreateVerticalLayout();
};

class ClientSqlTableModel : public QSqlRelationalTableModel
{
    Q_OBJECT
public:
    ClientSqlTableModel(QObject * parent = 0, QSqlDatabase db = QSqlDatabase())
        : QSqlRelationalTableModel(parent,db) {;}
    QVariant data (const QModelIndex & index, int role = Qt::DisplayRole) const
    {
        if (role == Qt::TextAlignmentRole) {
            int col = index.column();
            if (col == 0 || col == 4 || col == 12 || col == 13 || col == 14 || col == 15) {
                return QVariant(Qt::AlignVCenter | Qt::AlignHCenter);
            }
        }

        if (role == Qt::FontRole) {
            return QVariant (QFont("Helvetica57-Condensed"));
        }

        return QSqlRelationalTableModel::data(index,role);
    }
};

#endif // CLIENTMODULE_H
